﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WeifenLuo.WinFormsUI.Docking;

namespace SimplePad
{
    public static class FilesManager
    {
        private static Dictionary<string, FileHandler> _files = new Dictionary<string, FileHandler>();

        public static Dictionary<string, FileHandler> Files
        {
            get { return _files; }
        }

        public static DockPanel MainDockPanel { get; set; }

        public static void OpenFile(string filename)
        {
            if (MainDockPanel == null)
            {
                throw new Exception("Set MainDockPanel");
            }

            FileHandler file;
            if (_files.ContainsKey(filename))
            {
                file = _files[filename];
                file.Activate();
            }
            else
            {
                file = new FileHandler(filename, MainDockPanel);
                _files[filename] = file;
            }
        }

        public static void CloseFile(string filename)
        {
            _files.Remove(filename);
        }
    }
}
